<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>data Stream file template</title>
    <link href="<%=staticRelativePath%>/normalize.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
table{
    width: 100%;
}
table, th, td {
    border: 1px solid black;
    text-align: center;
}
th,span {
      font-weight: bold;
    }
td{
      font-weight: normal;
    }
.table-margin-top {
      margin-top: 20px;
    }
.td-context-left {
    text-align:left;
}
</style>
<body>
    <div>
        <div class="file-name">
            <h1>
                【<%= fileName%>】
            </h1>
        </div>
        <div><span>文件位置：<%= filePath %></span></div>
        <div><h2>函数调用信息</h2></div>
            <div class="table-margin-top"><span>函数调用列表</span></div>
            <div>
                <table>
                    <tbody>
                        <tr>
                            <th>函数</th>
                            <th>调用函数</th>
                            <th>调用函数所属文件</th>
                            <th>调用行号</th>
                        </tr>
                        <% for (let index = 0; index < functions.length; index +=1) { 
                            const func = functions[index];
                            const callingOtherFunctions = func.callingOtherFunctions; %>
                            <% for (let i = 0; i < callingOtherFunctions.length; i += 1 ) {
                                const invokeFunc = callingOtherFunctions[i]; %>
                                <tr>
                                    <td><%= func.functionName %></td>
                                    <td><%= invokeFunc.name %></td>
                                    <td><%= invokeFunc.filePath %></td>
                                    <td><%= invokeFunc.lines %></td>
                                </tr>
                            <%}%>
                        <% } %>
                    </tbody>
                </table>
            </div>
            <div class="table-margin-top"><span>函数被调用列表</span></div>
            <div>
                <table>
                    <tbody>
                        <tr>
                            <th>函数</th>
                            <th>被调用函数</th>
                            <th>被调用函数所属文件</th>
                            <th>被调用行号</th>
                        </tr>
                        <% for (let index = 0; index < functions.length; index +=1) { 
                            const func = functions[index];
                            const calledByOtherFunctions = func.calledByOtherFunctions; %>
                            <% for (let i = 0; i < calledByOtherFunctions.length; i += 1 ) {
                                const calledByOtherFunction = calledByOtherFunctions[i]; %>
                                <tr>
                                    <td><%= func.functionName %></td>
                                    <td><%= calledByOtherFunction.name %></td>
                                    <td><%= calledByOtherFunction.filePath %></td>
                                    <td><%= calledByOtherFunction.lines %></td>
                                </tr>
                            <%}%>
                        <% } %>
                    </tbody>
                </table>
            </div>
        <div class="table-margin-top"><span>数据流检查结果</span></div>
        <p>局部变量</p>
        <div>
            <table>
                <tbody>
                    <tr>
                        <th colspan="3" class="td-context-left">&ensp;UR：变量未定义就引用（未初始化）</th>
                    </tr>
                    <tr>
                        <th>变量</th>
                        <th>声明位置</th>
                        <th>引用位置</th>
                    </tr>
                    <% for (let i = 0; i < UR.length; i += 1) {
                       const item = UR[i];
                       const lines = UR[i].lines; %>
                       <tr>
                         <td><%= item.name %></td>
                         <td><%= item.declarationL %></td>
                         <td><%= item.referenceL %></td>
                       </tr>
                       <tr>
                        <td colspan="3" class="td-context-left"><% for (let j = 0; j < lines.length; j += 1 ) {
                            const l = lines[j]; %> 
                            Src Line <%= l.line %>:<%= l.content %><br/>
                            <%}%>
                        </td>
                       </tr>
                    <%}%>
                </tbody>
            </table>
        </div>
        <div class="table-margin-top">
            <table>
                <tbody>
                    <tr>
                        <th colspan="3" class="td-context-left">&ensp;DU：变量定义了但没有使用（在其作用域中没有使用）</th>
                    </tr>
                    <tr>
                        <th>变量</th>
                        <th>定义位置</th>
                        <th>终止位置</th>
                    </tr>
                    <% for (let i = 0; i < DU.length; i += 1) {
                       const item = DU[i];
                       const lines = DU[i].lines; %>
                       <tr>
                         <td><%= item.name %></td>
                         <td><%= item.definitionL %></td>
                         <td><%= item.terminationL %></td>
                       </tr>
                       <tr>
                        <td colspan="3" class="td-context-left"><% for (let j = 0; j < lines.length; j += 1) {
                            const l = lines[j]; %> 
                            Src Line <%= l.line %>:<%= l.content %><br/>
                            <%}%>
                        </td>
                       </tr>
                    <%}%>
                </tbody>
            </table>
        </div>
        <div class="table-margin-top">
            <table>
                <tbody>
                    <tr>
                        <th colspan="3" class="td-context-left">&ensp;DD：两次变量定义之间没有被使用</th>
                    </tr>
                    <tr>
                        <th>变量</th>
                        <th>定义位置</th>
                        <th>再次定义位置</th>
                    </tr>
                    <% for (let i = 0; i < DD.length; i += 1) {
                       const item = DD[i];
                       const lines = DD[i].lines; %>
                       <tr>
                         <td><%= item.name %></td>
                         <td><%= item.definitionL %></td>
                         <td><%= item.redefineL %></td>
                       </tr>
                       <tr>
                        <td colspan="3" class="td-context-left"><% for (let j = 0; j < lines.length; j += 1 ) {
                            const l = lines[j]; %> 
                            Src Line <%= l.line %>:<%= l.content %><br/>
                            <%}%>
                        </td>
                       </tr>
                    <%}%>
                </tbody>
            </table>
        </div>
        <p>全局变量</p>
        <div>
            <table>
                <tbody>
                    <tr>
                        <th colspan="2" class="td-context-left">&ensp;只引用（全局变量的值在函数中被引用但没有被改变）</th>
                    </tr>
                    <tr>
                        <th>变量</th>
                        <th>引用位置</th>
                    </tr>
                    <% for (let i = 0; i < globalsRefOnly.length; i += 1) {
                       const item = globalsRefOnly[i];
                       const lines = globalsRefOnly[i].lines; %>
                       <tr>
                         <td><%= item.name %></td>
                         <td><%= item.referenceL %></td>
                       </tr>
                       <tr>
                        <td colspan="2" class="td-context-left"><% for (let j = 0; j < lines.length; j += 1 ) {
                            const l = lines[j]; %> 
                            Src Line <%= l.line %>:<%= l.content %><br/>
                            <%}%>
                        </td>
                       </tr>
                    <%}%>
                </tbody>
            </table>
        </div>
        <div>
            <table>
                <tbody>
                    <tr>
                        <th colspan="2" class="td-context-left">&ensp;只定义（全局变量在函数中只被赋值，但在函数中没有被引用）</th>
                    </tr>
                    <tr>
                        <th>变量</th>
                        <th>定义位置</th>
                    </tr>
                    <% for (let i = 0; i < globalsDefOnly.length; i += 1) {
                       const item = globalsDefOnly[i];
                       const lines = globalsDefOnly[i].lines; %>
                       <tr>
                         <td><%= item.name %></td>
                         <td><%= item.definitionL %></td>
                       </tr>
                       <tr>
                        <td colspan="2" class="td-context-left"><% for (let j = 0; j < lines.length; j += 1 ) {
                            const l = lines[j]; %> 
                            Src Line <%= l.line %>:<%= l.content %><br/>
                            <%}%>
                        </td>
                       </tr>
                    <%}%>
                </tbody>
            </table>
        </div>
        <div>
            <table>
                <tbody>
                    <tr>
                        <th colspan="2" class="td-context-left">&ensp;全局变量既被定义也被引用和改变</th>
                    </tr>
                    <tr>
                        <th>变量</th>
                        <th>定义位置</th>
                    </tr>
                    <% for (let i = 0; i < globalsDefRefMod.length; i += 1) {
                       const item = globalsDefRefMod[i];
                       const lines = globalsDefRefMod[i].lines; %>
                       <tr>
                         <td><%= item.name %></td>
                         <td><%= item.defRefModL %></td>
                       </tr>
                       <tr>
                        <td colspan="2" class="td-context-left"><% for (let j = 0; j < lines.length; j += 1 ) {
                            const l = lines[j]; %> 
                            Src Line <%= l.line %>:<%= l.content %><br/>
                            <%}%>
                        </td>
                       </tr>
                    <%}%>
                </tbody>
            </table>
        </div>
        <p>变量分析</p>
        <div>
            <table>
                <tbody>
                    <tr>
                        <th>变量</th>
                        <th>所属函数</th>
                        <th>变量种类</th>
                        <th>变量类型</th>
                        <th>变量作用</th>
                        <th>位置</th>
                    </tr>
                    <% for (let i = 0; i < variables.length; i += 1) {
                       const item = variables[i]; %>
                       <tr>
                         <td><%= item.name %></td>
                         <td><%= item.functionName %></td>
                         <td><%= item.categoryName %></td>
                         <td><%= item.type %></td>
                         <td><%= item.scope %></td>
                         <td><%= item.locations %></td>
                       </tr>
                    <%}%>
                </tbody>
            </table>
        </div>

    </div>
</body>

</html>
